#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
@File    :   cookies_1.py
@Time    :   2024/11/29 13:51:52
@Author  :   xiangyu Chen
@Version :   1.0
@Contact :   yu112yu@sina.com
@License :   (C)Copyright 2017-2018, Liugroup-NLPR-CASIA
@Desc    :   None
'''

import requests
import requests.utils
from cacheout import Cache

cache = Cache()


# 调用登录接口
def login():
    url = "https://baidu.com"
    # body = {"account":"admin","password":"123456","passwordStrength":0}
    response = requests.get(url)
    cookies = requests.utils.dict_from_cookiejar(response.cookies)  # 转化位Python对象
    cookie_jar = requests.utils.cookiejar_from_dict(cookies, cookiejar=None, overwrite=True)  # 生成cookies对象
    cache.set('cookie_jar', cookie_jar)  # 将cookies 保存到本地缓存中。
    print(response.cookies)


if __name__ == '__main__':
    login()
    print(cache.items())
